#pragma once
#include "SimpleCanvas.h"
#include "graphics/Point.h"
#include <vector>

namespace yzrilyzr_simplecanvas{
	enum UIEventType{
		TYPE_KEY_EVENT,
		TYPE_MOTION_EVENT
	};
	enum UIEventAction{
		ACTION_UP,
		ACTION_DOWN,
		ACTION_MOVE,
	};
	enum KeyCode{
		KC_0=0x20,
		KC_1=0x21,
		KC_A=0x40,
		KC_a=0x60
	};

	EBCLASS(UIEvent){
	public:
	UIEventType type;
	};

	ECLASS(KeyEvent, public UIEvent){
	private:
	KeyCode code;
	UIEventAction action;
	public:
	KeyEvent(KeyCode code, UIEventAction action):code(code), action(action){
		type=UIEventType::TYPE_KEY_EVENT;
	}
	KeyEvent(){
		type=UIEventType::TYPE_KEY_EVENT;
	}
	KeyCode getCode(){
		return code;
	}
	UIEventAction getAction(){
		return action;
	}
	};
	ECLASS(MotionEvent, public UIEvent){
	private:
	UIEventAction action;
	std::vector<PointF> points;
	public:
	MotionEvent(){
		type=UIEventType::TYPE_MOTION_EVENT;
	}
	UIEventAction getAction(){
		return action;
	}
	float getX(){
		return getX(0);
	}
	float getX(u_index index){
		if(points.size() == 0)return 0;
		PointF & p=points[index];
		return p.x;
	}
	float getY(){
		return getY(0);
	}
	float getY(u_index index){
		if(points.size() == 0)return 0;
		PointF & p=points[index];
		return p.y;
	}
	u_index getPointerCount(){
		return points.size();
	}
	};
}